<?php

class Zend_View_Helper_Comments extends Zend_View_Helper_Abstract
{
    function comments($comments, $article)
    {
        $out = '<ul>';
        foreach ($comments as $record) {
            $out .= '<li>';
            $out .= $record['text'];
            $out .= <<<_ADD_URL
            <a href="#" class="comment-form" id="comment_{$article}_{$record['id']}">Add comment </a>
_ADD_URL;
            if (count($record['children'])) {
                $out .= $this->comments($record['children'], $article);
            }

            $out .= '</li>';
        }
        $out .= '</ul>';

        return $out;
    }
}
